package work.chief.service.impl;

import work.chief.dao.UserDao;
import work.chief.dao.impl.UserDaoImpl;
import work.chief.entity.User;
import work.chief.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();

    @Override
    public User selectByUsernameAndPassword(String username, String password) {
        return userDao.selectByUsernameAndPassword(username, password);
    }

    @Override
    public boolean selectByPhoneNum(String phone_number) {
        User user = userDao.selectByPhoneNum(phone_number);
        /**
         * user==null
         * 数据库里没找到相同号码
         * 名字合法
         * 返回true
         */
        if (user == null) {
            return true;
        } else
            return false;
    }

    @Override
    public boolean selectByUserName(String username) {
        User user = userDao.selectByUserName(username);
        /**
         * user==null
         * 数据库里没找到相同名字
         * 名字合法
         * 返回true
         */
        if (user == null) {
            return true;
        }
        return false;
    }

    @Override
    public int register(User user) {
        return userDao.register(user);
    }

    @Override
    public User selectByUsernameAndPasswordAndManager(String username, String password, int manager) {
        return userDao.selectByUsernameAndPasswordAndManager(username, password, manager);
    }

    @Override
    public List<User> selectAll() {
        return userDao.selectAll();
    }

    @Override
    public List<User> selectPage(Integer currentPage, Integer pageSize) {


        return userDao.selectPage(currentPage, pageSize);
    }

    @Override
    public Integer selectPageCount() {
        return userDao.selectPageCount();
    }

    @Override
    public int updateManager(int id, int manager) {


        return userDao.updateManager(id, manager);
    }

    @Override
    public int deleteUsers(String ids) {
        return userDao.deleteUsers(ids);
    }

}